home *** CD-ROM | disk | FTP | other *** search
- Path: news.compuserve.com!newsmaster
- From: 100435.736@compuserve.com (David A. Mair)
- Newsgroups: comp.lang.c
- Subject: Re: Check if a file exists?
- Date: Mon, 15 Apr 1996 07:45:19 GMT
- Organization: CompuServe Incorporated
- Message-ID: <4ksuqi$gls@arl-news-svc-5.compuserve.com>
- References: <4kp7pg$upe@news-s01.ny.us.ibm.net>
- NNTP-Posting-Host: dd15-052.compuserve.com
- X-Newsreader: Forte Free Agent 1.0.82
-
- bfilone@ibm.net <Bruce Filone> wrote:
-
- >Is it possible in C to check if a file exists other than checking for a succesful
- >fopen? ON a unix machine, I just want to know if a file is there or not, do not
- >to read or write anything to it. similar to the -f test in unix? I was hoping for
- >something less costly than opening and closing if exists because I am checking
- >for the existance of many files during the run of a process
- >Did not see any postings that seemed to refer to this.
- >Thanks in advance.
- >Bruce
-
-
- Well, depending on the environment you could open the directory and
- search it for the filename. Some PC based C compilers support an
- open_dir() function, it may be supported in other environments but I
- only know PCs. I have never used it but if you are working on a PC
- with a mainstream compiler it may help. There is also the MS-DOS
- FindFirst/FindNext operation which reads the directory looking for
- something you specify, although clearly this is a MS-DOS function and
- not part of the standard C RTL.
-
- Regards
- David.
-
-